<div class="line">
  <div class="title">
    <% if fetion.full? %>
    <div class="full">
      <%= image_tag 'lite_fetion/full.png' %>
    </div>
    <% end %>
    <div class='name'>
      <b class='<%= fetion.full? ? 'full' : '' %>'>
        <%= link_to_remote image_tag("lite_fetion/#{fetion.standing}.png"),
            :update => "lite_fetion_#{fetion.id}",
            :url => invert_standing_lite_fetion_url(fetion),
            :method => :put,
            :loading => nano_loading("fetion_#{fetion.id}_standing", :only_img => true),
            :html => {
              :id => "fetion_#{fetion.id}_standing",
              :title => "当前为#{fetion.standing},点击反转"
            }
        %>
        <%= fetion.name %>
      </b><%= fetion.mobile %>
    </div>        
    <div class='status <%= fetion.status %>'>
      <%= t fetion.status %>
    </div>          
  </div>
  <div>              
    <div class="info">
      <div class="me">
        <dl>
          <dt>上限：</dt>
          <dd><b><%= fetion.max_users_count %></b>人</dd>
        </dl>
        <dl>
          <dt>当前：</dt>
          <dd><b class='l'><%= fetion.users_count %></b>人</dd>
        </dl>   
        <dl class='persent'>
          <dt>入座率：</dt>
          <dd >
            <b><%= number_with_precision fetion.seat_percent, :precision => 2 %></b>%
          </dd>
        </dl>
      </div>
    </div>
    <div class="messages">
      <% if fetion.unread_application_confirmed_messages_count > 0 %>
      <dl>
        <dt>
          应用确认：
        </dt>
        <dd>
          <b><%= fetion.unread_application_confirmed_messages_count %></b>条
        </dd>
      </dl>
      <% end %>
      <% if fetion.unread_buddy_application_messages_count > 0 %>
      <dl>
        <dt>
          好友应用：
        </dt>
        <dd>
          <b><%= fetion.unread_buddy_application_messages_count %></b>条
        </dd>
      </dl>
      <% end %>
      <% if fetion.unread_buddy_messages_count > 0 %>
      <dl>
        <dt>
          好友消息：
        </dt>
        <dd>
          <b><%= fetion.unread_buddy_messages_count %></b>条
        </dd>
      </dl>
      <% end %>
      <% if fetion.unread_client_state_messages_count > 0 %>
      <dl>
        <dt>
          好友状态：
        </dt>
        <dd>
          <b><%= fetion.unread_buddy_state_messages_count %></b>条
        </dd>
      </dl>
      <% end %>
      <% if fetion.unread_client_state_messages_count > 0 %>
      <dl>
        <dt>
          自身状态：
        </dt>
        <dd>
          <b class='l'><%= fetion.unread_client_state_messages_count %></b>条
        </dd>
      </dl>
      <% end %>
    </div>
    <div class="stat">
      <dl class="l">
        <dd>
          创建于<%= time_ago_in_words fetion.created_at,false %>前
        </dd>
      </dl>
      <% if fetion.logined_at %>
      <dl class="l">
        <dd>
          登录于<%= time_ago_in_words fetion.logined_at,false %>前
        </dd>
      </dl>
      <% end %>
    </div>
  </div>
  <div class="tools">
    <div>
      <%= link_to '编辑', edit_lite_fetion_url(fetion) %>
    </div>      
    <div>
      <%= link_to_function '查看消息', "show_or_hide_messages('#{fetion.id}')", :id => "show_or_hide_fetion_#{fetion.id}_messages" %>
    </div>
    <% if fetion.allow_login? %>
    <div>
      <%= link_to_remote '登录', 
            :update => "lite_fetion_#{fetion.id}_login",
            :url => login_verify_lite_fetion_url(fetion),
            :method => :get,
            :loading => nano_loading("fetion_#{fetion.id}_login"),      
            :complete => "$('lite_fetion_#{fetion.id}_login').show();$('fetion_#{fetion.id}_login').update('登录')",
            :html => {
              :id => "fetion_#{fetion.id}_login"
            }
       %>          
    </div>
    <% end %>
    <% if fetion.allow_logout? %>
    <div>
      <%= link_to_remote '注销',
            :update => "lite_fetion_#{fetion.id}",
            :url => logout_lite_fetion_url(fetion),
            :method => :put,
            :loading => nano_loading("fetion_#{fetion.id}_logout"),
            :html => {
              :id => "fetion_#{fetion.id}_logout"
            }
       %> 
    </div>
    <% end %>
  </div>
</div>
<div id="lite_fetion_<%= fetion.id%>_login" class='line fetion_verify corner' style='display:none;'>
  
</div>
<div id="lite_fetion_<%= fetion.id%>_add_friend_verify" class='line fetion_verify corner' style='display:none;'>
  
</div>
<div id="lite_fetion_<%= fetion.id %>_messages" class="line" style="display:none;">
  <div class='tabs'=>
    <%= link_to_function '全部', 
        "fetion_#{fetion.id}_unread_messages('FetionMessage');h_tab(#{fetion.id},this)", 
        :class => "tab head_corner h" %>
    <%= link_to_function FetionMessage::ApplicationConfirmed.human_name, 
          "fetion_#{fetion.id}_unread_messages('FetionMessage::ApplicationConfirmed');h_tab(#{fetion.id},this)",  
          :class => "tab head_corner" %>
    <%= link_to_function FetionMessage::BuddyApplication.human_name, 
          "fetion_#{fetion.id}_unread_messages('FetionMessage::BuddyApplication');h_tab(#{fetion.id},this)",  
          :class => "tab head_corner" %>
    <%= link_to_function FetionMessage::BuddyMessage.human_name, 
          "fetion_#{fetion.id}_unread_messages('FetionMessage::BuddyMessage');h_tab(#{fetion.id},this)",  
          :class => "tab head_corner" %>
    <%= link_to_function FetionMessage::BuddyState.human_name, 
          "fetion_#{fetion.id}_unread_messages('FetionMessage::BuddyState');h_tab(#{fetion.id},this)",  
          :class => "tab head_corner" %>
    <%= link_to_function FetionMessage::ClientState.human_name, 
          "fetion_#{fetion.id}_unread_messages('FetionMessage::ClientState');h_tab(#{fetion.id},this)",  
          :class => "tab head_corner" %>
    
    <% form_tag '#', :id => "fetion_#{fetion.id}_messages_form" do %>
      <%= hidden_field_tag 'page', nil,:id => "fetion_#{fetion.id}_page" %>
      <%= hidden_field_tag 'type', nil,:id => "fetion_#{fetion.id}_type" %>
    <% end %>  
  </div>
  <div id='fetion_<%= fetion.id %>_messages' class='corner_but_top_left fetion_messages'>
    <script type="text/javascript" charset="utf-8">
      function fetion_<%= fetion.id %>_unread_messages(type) {            
        $('fetion_<%= fetion.id %>_type').value = type;
        fetion_<%= fetion.id %>_go_to(1);
      }
                
      function fetion_<%= fetion.id %>_go_to(page) {
        $('fetion_<%= fetion.id %>_page').value = page;
        <%= remote_function :update => "fetion_#{fetion.id}_messages",
              :url => messages_lite_fetions_url(:id => fetion.id),
              :method => :get,
              :loading => normal_loading("fetion_#{fetion.id}_messages",:height => '200px'),
              :with => "$('fetion_#{fetion.id}_messages_form').serialize()"
         %>
      }
    </script>
  </div>
</div>